#include<iostream>
#include<string>

using namespace std;

class Solution {
public:
    bool backspaceCompare(string s, string t) {
        return changestr(s) == changestr(t);
    }

    string changestr(string s)
    {
        string ret;
        for (auto ch : s)
        {
            if (ch != '#')
            {
                ret += ch;
            }
            else
            {
                if (ret.size())
                {
                    ret.pop_back();
                }
            }
        }

        for (auto ch : ret)
        {
            cout << ch;
        }

        cout << endl;
        return ret;
    }
};

int main()
{
    string s = "y#fo##f";
    string t = "y#f#o##f";
    Solution sol;
    sol.backspaceCompare(s, t);
    return 0;
}